package com.xinke.module.system.mapper.logger;

import java.util.*;

import com.xinke.component.common.pojo.PageResult;
import com.xinke.component.mybatis.mybatis.core.query.LambdaQueryWrapperExt;
import com.xinke.component.mybatis.mybatis.core.mapper.BaseMapperExt;
import com.xinke.module.system.model.entity.logger.LoginLogDO;
import org.apache.ibatis.annotations.Mapper;
import com.xinke.module.system.model.vo.logger.*;

/**
 * 系统访问记录 Mapper
 *
 * @author yzx
 */
@Mapper
public interface LoginLogMapper extends BaseMapperExt<LoginLogDO> {

    default PageResult<LoginLogDO> selectPage(LoginLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperExt<LoginLogDO>()
                .eqIfPresent(LoginLogDO::getLogType, reqVO.getLogType())
                .eqIfPresent(LoginLogDO::getTraceId, reqVO.getTraceId())
                .eqIfPresent(LoginLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(LoginLogDO::getUserType, reqVO.getUserType())
                .likeIfPresent(LoginLogDO::getUserName, reqVO.getUserName())
                .eqIfPresent(LoginLogDO::getLoginResult, reqVO.getLoginResult())
                .eqIfPresent(LoginLogDO::getUserIp, reqVO.getUserIp())
                .eqIfPresent(LoginLogDO::getUserAgent, reqVO.getUserAgent())
                .orderByDesc(LoginLogDO::getLogId));
    }

}